package leetcode;

/**
 * 描述:
 *
 * @author Madison You
 * @created 22:56
 */
public class Easy_27_RemoveElement {

    public static void main(String[] args) {
        int[] ints = {3,3};
        new Easy_27_RemoveElement().removeElement(ints, 3);
    }

    public int removeElement(int[] nums, int val) {
        int left = 0;
        int right = nums.length - 1;
        while (left <= right) {
            if (nums[right]==val) {
                right--;
                continue;
            }
            if(nums[left] == val) {
                nums[left] = nums[right];
                right--;
            }
            left++;
        }
        return left;
    }
}
